using UnityEngine;
using System.Collections;

public class Home : MonoBehaviour {

	public GUISkin mySkin;
	public Renderer player;
	Renderer lastPlayer;
	string playerName = "";

	void Start()
	{
		lastPlayer = player;
		objectDown(1,player);
	}
		
	public void objectDown(int value, Renderer objeto)
	{
		lastPlayer.renderer.material.color = Color.white;
		objeto.renderer.material.color = Color.red;
		PlayerPrefs.SetInt("CorJogador",value);
		lastPlayer.gameObject.SendMessage("notYourPlayer",SendMessageOptions.DontRequireReceiver);
		objeto.gameObject.SendMessage("yourPlayer",SendMessageOptions.DontRequireReceiver);
		lastPlayer = objeto;
	}
	
	void OnGUI () 
	{
		GUI.skin = mySkin;

		playerName = GUI.TextField(new Rect(630,320,200,40),playerName,16);
		
		if(GUI.Button(new Rect(645,485,70,40),"Iniciar"))
		{
			PlayerPrefs.SetString("Nome",playerName);
			Application.LoadLevel("Game");
		}
		
		if(GUI.Button(new Rect(745,485,70,40),"Limpar"))
		{
			playerName = "";
		}
	}
}
